"use strict";
const mongoose = require("mongoose");
let schema = null;
const createSchema = function() {
	//组织和套件之间的关联，即购买关系
	const suitePrototype = {
		suiteKey: {
			type: String,
			ref: "Suite"
		},
		tempAuthCode: String, //临时授权码，一旦套件被购买就推送，只会推送一次
		permanentCode: String, //永久授权码
		domainId: String,
		orgId: String
	};
	schema = new mongoose.Schema(suitePrototype);
};
const createIndex = function() {
	schema.index({
		suiteKey: 1,
		domainId: 1,
		orgId: 1,
		unique: true
	});
};
createSchema();
createIndex();
mongoose.model("SuiteToOrg", schema);